<template>

	<!-- Billing Information Card -->
	<a-card :bordered="false" class="header-solid h-full" :bodyStyle="{paddingTop: 0, paddingBottom: '16px' }">
		<template #title>
			<h5 class="font-semibold m-0">审核员申请审核</h5>
		</template>
		<a-row :gutter="[24, 24]">

			<a-col :span="24">
        <el-empty v-if="reviewList.length===0"></el-empty>
			<a-card :bordered="false" class="card-billing-info" v-for="item in reviewList" style="margin-top: 10px">

        <div class="col-info" >
          <a-descriptions :title=item.name :column="1">

            <a-descriptions-item label="用户ID">
              {{ item.userId }}
            </a-descriptions-item>
						<a-descriptions-item label="年龄">
              {{ item.age }}
						</a-descriptions-item>
						<a-descriptions-item label="联系方式">
							{{item.contact}}
						</a-descriptions-item>
						<a-descriptions-item label="学历">
              {{ item.edu }}
						</a-descriptions-item>
            <a-descriptions-item label="申请理由">
              {{item.reason}}
            </a-descriptions-item>
					</a-descriptions>
				</div>
				<div class="col-action">
					<a-button type="link" size="small" @click="dissAgreeReview(item.userId,item.reviewApplyId,'已拒绝')">
            <a-icon type="close-circle" theme="filled" style="color: #F5222D"/>
						<span class="text-danger">拒绝</span>
					</a-button>
					<a-button type="link" size="small" @click="agreeReview(item.userId,item.reviewApplyId,'已审核')">
            <a-icon type="check-circle" theme="filled" />
						<span class="text-dark">同意</span>
					</a-button>
				</div>
			</a-card>
			</a-col>

		</a-row>
	</a-card>
	<!-- / Billing Information Card -->

</template>

<script>

	export default ({
		data() {
			return {
        reviewList: {},
        reviewApply:{
          userId:'',
          status:'',
          reviewApplyId: 0
        }
			}
		},
    methods:{
      getData(){
        this.$axios({
          headers: {
            "Content-Type": "application/json;charset=UTF-8",
            "Authorization": sessionStorage.getItem("systemToken")
          },
          url: "/api/review/getAllReviewApplyNoCheck", //后端请求的路径
          method: "get",
        }).then((response) => {
          // console.log(response.data)
          if (response.data.status === 0) {
            this.reviewList = response.data.data
            console.log(this.reviewList)
            console.log("111")
          }
        });
      },
      agreeReview(userId,reviewApplyId,status){
        this.reviewApply.userId = userId
        this.reviewApply.reviewApplyId = reviewApplyId
        this.reviewApply.status = status
        this.$axios({
          headers: {
            "Content-Type": "application/json;charset=UTF-8",
            "Authorization": sessionStorage.getItem("systemToken")
          },
          url: "/api/review/updateReviewApply", //后端请求的路径
          method: "post",
          data: this.reviewApply
        }).then((response) => {
          // console.log(response.data)
          if (response.data.status === 0) {
            this.$message({
              message: '操作成功',
              type: 'success'
            });
            location.reload()
          }else{
            this.$message.error('操作失败');
          }
        });
      },
      dissAgreeReview(userId,reviewApplyId,status){
        this.reviewApply.userId = userId
        this.reviewApply.reviewApplyId = reviewApplyId
        this.reviewApply.status = status
        this.$axios({
          headers: {
            "Content-Type": "application/json;charset=UTF-8",
            "Authorization": sessionStorage.getItem("systemToken")
          },
          url: "/api/review/updateReviewApply", //后端请求的路径
          method: "post",
          data: this.reviewApply
        }).then((response) => {
          // console.log(response.data)
          if (response.data.status === 0) {
            this.$message({
              message: '操作成功',
              type: 'success'
            });
            location.reload()
          }else{
            this.$message.error('操作失败');
          }
        });
      }
    },
    mounted() {
      this.getData()
    }
  })

</script>